package j08string;

public class J1 {
    public static void main(String[] args) {
        String s1 = "a";
        s1 += "b";
        System.out.println("s1 = " + s1);
        System.out.println("======");
        System.out.println(new String());//""
        System.out.println(new String(new char[]{97,98}));//"ab"
        char[] arr = {'a','b','c','d','e'};
        System.out.println(new String(arr,1,2));//bc


        byte b1 = 'a';
        System.out.println("b1 = " + b1);
    }
}

class J2{
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "abc";
        System.out.println(s1 == s2);//true

        String s3 = new String("xx");
        String s4 = new String("xx");
        System.out.println(s3==s4);//false

        System.out.println(s3.equals(s4));//true
        System.out.println(s1.equals(s2));//true
        System.out.println("=====");
        System.out.println("Aa".equals("aa"));//false
        System.out.println("Aa".equalsIgnoreCase("aa"));//true

        System.out.println("abc".length());//3

        char c1 = "abc".charAt(0);//c1=a
        System.out.println("c1 = " + c1);
        System.out.println("a\nb".length());//? = 3
        try {
            System.out.println("abc".charAt(10000));
        }catch (Exception e){
            e.printStackTrace();
        }

        System.out.println("end");

    }
}
class J3{
    public static void main(String[] args) {
//        System.out.println("abc">"ttt");
        System.out.println("a".compareTo("b"));//-1
        System.out.println("b".compareTo("b"));//0
        System.out.println("c".compareTo("b"));//1
        System.out.println("aa".compareTo("bc"));//

        String s1 = "a";
        String s2 = s1.concat("x");
        System.out.println("s1 = " + s1);
        System.out.println("s2 = " + s2);

        System.out.println(s1+"x");//ax

        System.out.println("=====");
        String ss = "abcdef";
        System.out.println(ss.contains("a"));//true
        System.out.println(ss.contains("abc"));//true
        System.out.println(ss.contains("bc"));//true
        System.out.println(ss.contains("af"));//false
        System.out.println(">>>>>>");
        System.out.println(ss.startsWith("a"));//true
        System.out.println(ss.startsWith("ab"));//true
        System.out.println(ss.startsWith("b"));//false
        System.out.println(ss.startsWith("fb"));//false

    }
}